/* UrlDemo.java 
* Created on Nov 29, 2012 
*@Author: Mr.Viet 
*@Phone: 01683430426 
*@Email: phamvanvietcdhd@gmail.com
*/ 
package com.session7; 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

import javax.print.DocFlavor.INPUT_STREAM;

public class UrlDemo {

	public UrlDemo() {
	}

	public static void main(String[] args) {
		try {
			URL url = new URL("http://dantri.com.vn");
			InputStream stream = url.openStream();
			BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
			String str = null;
			while((str = reader.readLine())!=null){
				System.out.println(str);
			}
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
